package com.ruoyi.project.posts.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.posts.domain.LblCsDealClassify;
import com.ruoyi.project.posts.service.ILblCsDealClassifyService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 二手交易商品分类Controller
 * 
 * @author BaoL
 * @date 2023-03-26
 */
@RestController
@RequestMapping("/posts/GoodsClassify")
public class LblCsDealClassifyController extends BaseController
{
    @Autowired
    private ILblCsDealClassifyService lblCsDealClassifyService;

    /**
     * 查询二手交易商品分类列表
     */
    @PreAuthorize("@ss.hasPermi('posts:GoodsClassify:list')")
    @GetMapping("/list")
    public TableDataInfo list(LblCsDealClassify lblCsDealClassify)
    {
        startPage();
        List<LblCsDealClassify> list = lblCsDealClassifyService.selectLblCsDealClassifyList(lblCsDealClassify);
        return getDataTable(list);
    }

    /**
     * 导出二手交易商品分类列表
     */
    @PreAuthorize("@ss.hasPermi('posts:GoodsClassify:export')")
    @Log(title = "二手交易商品分类", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(LblCsDealClassify lblCsDealClassify)
    {
        List<LblCsDealClassify> list = lblCsDealClassifyService.selectLblCsDealClassifyList(lblCsDealClassify);
        ExcelUtil<LblCsDealClassify> util = new ExcelUtil<LblCsDealClassify>(LblCsDealClassify.class);
        return util.exportExcel(list, "GoodsClassify");
    }

    /**
     * 获取二手交易商品分类详细信息
     */
    @PreAuthorize("@ss.hasPermi('posts:GoodsClassify:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(lblCsDealClassifyService.selectLblCsDealClassifyById(id));
    }

    /**
     * 新增二手交易商品分类
     */
    @PreAuthorize("@ss.hasPermi('posts:GoodsClassify:add')")
    @Log(title = "二手交易商品分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LblCsDealClassify lblCsDealClassify)
    {
        return toAjax(lblCsDealClassifyService.insertLblCsDealClassify(lblCsDealClassify));
    }

    /**
     * 修改二手交易商品分类
     */
    @PreAuthorize("@ss.hasPermi('posts:GoodsClassify:edit')")
    @Log(title = "二手交易商品分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LblCsDealClassify lblCsDealClassify)
    {
        return toAjax(lblCsDealClassifyService.updateLblCsDealClassify(lblCsDealClassify));
    }

    /**
     * 删除二手交易商品分类
     */
    @PreAuthorize("@ss.hasPermi('posts:GoodsClassify:remove')")
    @Log(title = "二手交易商品分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(lblCsDealClassifyService.deleteLblCsDealClassifyByIds(ids));
    }
}
